Trigger for exclusive edit

Hello everybody.
I have this little doubt, in a module i have several triggers, most of them based in the modification of the object.
But after some thinking i thought it better if the trigger appear when the module is put on Exclusive Edit.
but how do i do it.
the function canModify can be used in this case
 

sFunction = "Object o = current Object "
    "if(canModify(obj))"

 


but i really don't know where to start

 


Bruwbruw - Thu Mar 22 12:31:12 EDT 2012

Re: Trigger for exclusive edit
llandale - Thu Mar 22 12:42:59 EDT 2012

Here is some pretty good standard code for the top of an attribute-save trigger.

Trigger    trg = current;           if (null trg)       halt()  // Error?
AttrDef ad  = attrdef(trg); if (null ad)        halt()  // Error?
Object  obj = object(trg);  if (null obj)       halt()  // Error?
Module  mod = module(obj);  if (null mod)       halt()  // Error?
bool    Dxl = ad.dxl;       if (Dxl)            halt()  // Allow Attr DXL modifications


However, I don't see the point of expressly looking for Exclusive edit, since this trigger will not fire unless the object is about to change (implying Edit or Shared and locked). If you did really want to, this should work (after the above)

 

  • if (!isEdit(mod)) halt


-Louie

Don't use "current Object" in the trigger as it may not be the one changing; use object(trg) as above. Also, don't use the generic "obj" parameter unless in a layout or attr-DXL.

 

Re: Trigger for exclusive edit
llandale - Thu Mar 22 12:45:20 EDT 2012

llandale - Thu Mar 22 12:42:59 EDT 2012

Here is some pretty good standard code for the top of an attribute-save trigger.

Trigger    trg = current;           if (null trg)       halt()  // Error?
AttrDef ad  = attrdef(trg); if (null ad)        halt()  // Error?
Object  obj = object(trg);  if (null obj)       halt()  // Error?
Module  mod = module(obj);  if (null mod)       halt()  // Error?
bool    Dxl = ad.dxl;       if (Dxl)            halt()  // Allow Attr DXL modifications


However, I don't see the point of expressly looking for Exclusive edit, since this trigger will not fire unless the object is about to change (implying Edit or Shared and locked). If you did really want to, this should work (after the above)

 

  • if (!isEdit(mod)) halt


-Louie

Don't use "current Object" in the trigger as it may not be the one changing; use object(trg) as above. Also, don't use the generic "obj" parameter unless in a layout or attr-DXL.

 

This gets the proposed value about to be assigned to the object:
  • string ValuProposed = value(trg)

-Louie

Re: Trigger for exclusive edit
Bruwbruw - Thu Mar 22 13:45:02 EDT 2012

Thank you. The problem is that one group will be importing several changes, and after it happens, the trigger appears several times. It stoped bein a good reminder, and started to become a problem.
But thanks.

Re: Trigger for exclusive edit
llandale - Thu Mar 22 15:13:59 EDT 2012

Bruwbruw - Thu Mar 22 13:45:02 EDT 2012
Thank you. The problem is that one group will be importing several changes, and after it happens, the trigger appears several times. It stoped bein a good reminder, and started to become a problem.
But thanks.

You saying you want to trigger in Shared mode but not Exclusive mode? Then the isEdit(mod) check should do it.

You saying you want some folks to disable the trigger? I see a "disable(Trigger)" perm that looks promising.

You could also perhaps create an "Import" user, and code the trigger so it doesn't fire for that particular user. ..err.. I mean it does fire, but ends gracefully without doing anything if it is.

-Louie